function J = getjac(x)
  nd = size(x.d);
  if(nd(2)==1)
    J = reshape(x.d,[nd(1) nd(3:end)]);
  else
    J = x.d;
  end
